﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="InstallViewModel.cs" company="ecblog.codeplex.com">
//   emrecoskun.net - ibrahimatay.com
// </copyright>
// <summary>
//   The install view model
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace EcBlog.Models
{
    using System.ComponentModel.DataAnnotations;
    using System.Web.Mvc;

    using EcBlog.Properties;

    /// <summary>
    /// The install view model
    /// </summary>
    public class InstallViewModel
    {
        /// <summary>
        /// Gets or sets the data source.
        /// </summary>
        /// <value>
        /// The data source.
        /// </value>
        [Display(Name = "InstallViewModel_DataSource", ResourceType = typeof(ModelLocalization)), 
        Required(ErrorMessageResourceType = typeof(ModelLocalization), ErrorMessageResourceName = "InstallViewMode_Requiredl_DataSource")]
        public string DataSource { get; set; }

        /// <summary>
        /// Gets or sets the connection string.
        /// </summary>
        /// <value>
        /// The connection string.
        /// </value>
        [Display(Name = "InstallViewModel_ConnectionString", ResourceType = typeof(ModelLocalization))]
        [Required(ErrorMessageResourceType = typeof(ModelLocalization), ErrorMessageResourceName = "InstallViewModel_Required_ConnectionString")]
        public string ConnectionString { get; set; }

        /// <summary>
        /// Gets or sets the name of the admin user.
        /// </summary>
        /// <value>
        /// The name of the admin user.
        /// </value>
        [Required(ErrorMessageResourceType = typeof(ModelLocalization), ErrorMessageResourceName = "InstallViewModel_Required_AdminUserName")]
        [Display(Name = "InstallViewModel_User_name", ResourceType = typeof(ModelLocalization))]
        public string AdminUserName { get; set; }

        /// <summary>
        /// Gets or sets the admin email.
        /// </summary>
        /// <value>
        /// The admin email.
        /// </value>
        [Required(ErrorMessageResourceType = typeof(ModelLocalization), ErrorMessageResourceName = "InstallViewModel_Required_AdminEmail")]
        [DataType(DataType.EmailAddress)]
        [Display(Name = "InstallViewModel_Email_address", ResourceType = typeof(ModelLocalization))]
        [RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessageResourceType = typeof(ModelLocalization), ErrorMessageResourceName = "InstallViewModel_Required_AdminEmail")]
        public string AdminEmail { get; set; }

        /// <summary>
        /// Gets or sets the admin password.
        /// </summary>
        /// <value>
        /// The admin password.
        /// </value>
        [Required(ErrorMessageResourceType = typeof(ModelLocalization), ErrorMessageResourceName = "InstallViewModel_Required_AdminPassword")]
        [DataType(DataType.Password)]
        [Display(Name = "InstallViewModel_Password", ResourceType = typeof(ModelLocalization))]
        public string AdminPassword { get; set; }

        /// <summary>
        /// Gets or sets the admin confirm password.
        /// </summary>
        /// <value>
        /// The admin confirm password.
        /// </value>
        [DataType(DataType.Password)]
        [Display(Name = "InstallViewModel_Confirm_password", ResourceType = typeof(ModelLocalization))]
        [Compare("AdminPassword", ErrorMessageResourceType = typeof(ModelLocalization),
            ErrorMessageResourceName = "RegisterViewModel_The_password_and_confirmation_password_do_not_match_")]
        public string AdminConfirmPassword { get; set; }

        /// <summary>
        /// Gets or sets the site title.
        /// </summary>
        /// <value>
        /// The site title.
        /// </value>
        [Display(Name = "InstallViewModel_SiteTitle", ResourceType = typeof(ModelLocalization)), 
        StringLength(50),
        Required(ErrorMessageResourceType = typeof(ModelLocalization), ErrorMessageResourceName = "InstallViewModel_Required_SiteTitle")]
        public string SiteTitle { get; set; }

        /// <summary>
        /// Gets or sets the site slogan.
        /// </summary>
        /// <value>
        /// The site slogan.
        /// </value>
        [Display(Name = "InstallViewModel_SiteSlogan", ResourceType = typeof(ModelLocalization)),
        StringLength(50),
        Required(ErrorMessageResourceType = typeof(ModelLocalization), ErrorMessageResourceName = "InstallViewModel_Required_SiteSlogan")]
        public string SiteSlogan { get; set; }

        /// <summary>
        /// Gets or sets the site URL.
        /// </summary>
        /// <value>
        /// The site URL.
        /// </value>
        [Display(Name = "InstallViewModel_SiteUrl", ResourceType = typeof(ModelLocalization)),
        StringLength(50),
        Required(ErrorMessageResourceType = typeof(ModelLocalization), ErrorMessageResourceName = "InstallViewModel_Required_SiteUrl")]
        public string SiteUrl { get; set; }

        /// <summary>
        /// Gets or sets the site description.
        /// </summary>
        /// <value>
        /// The site description.
        /// </value>
        [Display(Name = "InstallViewModel_SiteDescription", ResourceType = typeof(ModelLocalization)),
        StringLength(50),
        Required(ErrorMessageResourceType = typeof(ModelLocalization), ErrorMessageResourceName = "InstallViewModel_Required_SiteDescription")]
        public string SiteDescription { get; set; }

        /// <summary>
        /// Gets or sets the author.
        /// </summary>
        /// <value>
        /// The author.
        /// </value>
        [Display(Name = "InstallViewModel_Author", ResourceType = typeof(ModelLocalization)),
        StringLength(50),
         Required(ErrorMessageResourceType = typeof(ModelLocalization), ErrorMessageResourceName = "InstallViewModel_Required_Author")]
        public string Author { get; set; }

        /// <summary>
        /// Gets or sets the copyright.
        /// </summary>
        /// <value>
        /// The copyright.
        /// </value>
        [Display(Name = "InstallViewModel_Copyright", ResourceType = typeof(ModelLocalization)),
        StringLength(50)]
        [Required(ErrorMessageResourceType = typeof(ModelLocalization), ErrorMessageResourceName = "InstallViewModel_Required_Copyright")]
        public string Copyright { get; set; }

        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return false;
            }

            if (ReferenceEquals(this, obj))
            {
                return true;
            }

            if (obj.GetType() != typeof(InstallViewModel))
            {
                return false;
            }

            return this.Equals((InstallViewModel)obj);
        }

        /// <summary>
        /// Equals the specified other view model.
        /// </summary>
        /// <param name="other">The other view model.</param>
        /// <returns><c>true</c> equal view models, otherwise <c>false</c></returns>
        public bool Equals(InstallViewModel other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }

            if (ReferenceEquals(this, other))
            {
                return true;
            }

            return Equals(other.DataSource, this.DataSource)
                && Equals(other.ConnectionString, this.ConnectionString) 
                && Equals(other.AdminUserName, this.AdminUserName) 
                && Equals(other.AdminEmail, this.AdminEmail) 
                && Equals(other.AdminPassword, this.AdminPassword) 
                && Equals(other.AdminConfirmPassword, this.AdminConfirmPassword) 
                && Equals(other.SiteTitle, this.SiteTitle) 
                && Equals(other.SiteSlogan, this.SiteSlogan) 
                && Equals(other.SiteUrl, this.SiteUrl) 
                && Equals(other.SiteDescription, this.SiteDescription) 
                && Equals(other.Author, this.Author) 
                && Equals(other.Copyright, this.Copyright);
        }

        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
        /// </returns>
        public override int GetHashCode()
        {
            unchecked
            {
                int result = this.DataSource != null ? this.DataSource.GetHashCode() : 0;
                result = (result * 397) ^ (this.ConnectionString != null ? this.ConnectionString.GetHashCode() : 0);
                result = (result * 397) ^ (this.AdminUserName != null ? this.AdminUserName.GetHashCode() : 0);
                result = (result * 397) ^ (this.AdminEmail != null ? this.AdminEmail.GetHashCode() : 0);
                result = (result * 397) ^ (this.AdminPassword != null ? this.AdminPassword.GetHashCode() : 0);
                result = (result * 397) ^ (this.AdminConfirmPassword != null ? this.AdminConfirmPassword.GetHashCode() : 0);
                result = (result * 397) ^ (this.SiteTitle != null ? this.SiteTitle.GetHashCode() : 0);
                result = (result * 397) ^ (this.SiteSlogan != null ? this.SiteSlogan.GetHashCode() : 0);
                result = (result * 397) ^ (this.SiteUrl != null ? this.SiteUrl.GetHashCode() : 0);
                result = (result * 397) ^ (this.SiteDescription != null ? this.SiteDescription.GetHashCode() : 0);
                result = (result * 397) ^ (this.Author != null ? this.Author.GetHashCode() : 0);
                result = (result * 397) ^ (this.Copyright != null ? this.Copyright.GetHashCode() : 0);
                return result;
            }
        }
    } 
}